// @FileName  :line.c
// @Time      :2024/3/19 23:32
// @Author    :YKW
//# include <bits/stdc++.h>
//using namespace std;
# include <stdio.h>

struct line {
    int x1, y1, x2, y2;
    int nxt;
} a[1000];

void solve() {
    int n, ans, x, y, cnt = 1, tmp;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d%d%d%d", &a[i].x1, &a[i].y1, &a[i].x2, &a[i].y2), a[i].nxt = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            if (i == j) continue;
            else if (a[i].x2 == a[j].x1 && a[i].y2 == a[j].y1) a[i].nxt = j;
    for (int i = 1; i <= n; i++) {
        if (a[i].nxt) {
            cnt = 1, tmp = i;
            while (a[tmp].nxt) tmp = a[tmp].nxt, cnt++;
        }
        if (cnt > ans) {
            ans = cnt;
            x = a[i].x1;
            y = a[i].y1;
        }
    }
    printf("%d %d %d", ans, x, y);
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) solve();
    return 0;
}